package com.yj.jason.jsondemo;

import android.graphics.Color;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;

import com.yj.jason.moudlelibrary.view.ClockView;
import com.yj.jason.moudlelibrary.view.DashboardView;
import com.yj.jason.moudlelibrary.view.GramophoneView;
import com.yj.jason.moudlelibrary.view.HighlightCR;
import com.yj.jason.moudlelibrary.view.MergePictureView;
import com.yj.jason.moudlelibrary.view.ScoreTrend;
import com.yj.jason.moudlelibrary.view.TemperatureProgress;
import com.yj.jason.moudlelibrary.view.TickView;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

public class CustomerActivity extends AppCompatActivity{

    ScoreTrend scoreTrend;
    int score[] = new int[6];


    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_customer);

        final GramophoneView gramophoneView = (GramophoneView)findViewById(R.id.gramophone_view);
        final Button button = (Button)findViewById(R.id.btn_play_pause);
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if(gramophoneView.getPlaying()){
                    button.setText("点击播放");
                }else{
                    button.setText("点击暂停");
                }
                gramophoneView.setPlaying(!gramophoneView.getPlaying());
            }
        });

        ClockView clockView = (ClockView)findViewById(R.id.clock_view);
        clockView.setTime(8, 20, 40);
        clockView.star();


        //四张图片合并效果
       // int[] resourceIdForth = new int[]{R.drawable.gramophone_view_default_picture, R.drawable.gramophone_view_default_picture, R.drawable.gramophone_view_default_picture, R.drawable.gramophone_view_default_picture};
        int[] resourceIdForth = new int[]{R.drawable.gramophone_view_default_picture, R.drawable.gramophone_view_default_picture, R.drawable.gramophone_view_default_picture};
       // int[] resourceIdForth = new int[]{R.drawable.gramophone_view_default_picture, R.drawable.gramophone_view_default_picture};
       // int[] resourceIdForth = new int[]{R.drawable.gramophone_view_default_picture};
        ((MergePictureView)findViewById(R.id.merge_picture_view_forth)).setDrawableIds(resourceIdForth);



        TemperatureProgress circleProgress = (TemperatureProgress)findViewById(R.id.circle_progress);
        circleProgress.setTemperature(40, 24, 12);




        final TickView tickView = (TickView) findViewById(R.id.tick_view);
        final Button btn = (Button)findViewById(R.id.btn_change_select);
        btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if(tickView.getCheck()){
                    button.setText("点击选中");
                }else{
                    button.setText("点击取消");
                }
                tickView.setCheck(!tickView.getCheck());
            }
        });





        final DashboardView dashboardView1 = (DashboardView) findViewById(R.id.dashboard_view_2);
        DashboardView dashboardView3 = (DashboardView) findViewById(R.id.dashboard_view_3);
        DashboardView dashboardView4 = (DashboardView) findViewById(R.id.dashboard_view_4);
        dashboardView1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dashboardView1.setRealTimeValue(150.f, true, 100);
            }
        });

        List<HighlightCR> highlight1 = new ArrayList<>();
        highlight1.add(new HighlightCR(210, 60, Color.parseColor("#03A9F4")));
        highlight1.add(new HighlightCR(270, 60, Color.parseColor("#FFA000")));
        dashboardView1.setStripeHighlightColorAndRange(highlight1);

        List<HighlightCR> highlight2 = new ArrayList<>();
        highlight2.add(new HighlightCR(170, 140, Color.parseColor("#607D8B")));
        highlight2.add(new HighlightCR(310, 60, Color.parseColor("#795548")));
        dashboardView3.setStripeHighlightColorAndRange(highlight2);

        dashboardView4.setRadius(110);
        dashboardView4.setArcColor(getResources().getColor(android.R.color.black));
        dashboardView4.setTextColor(Color.parseColor("#212121"));
        dashboardView4.setBgColor(getResources().getColor(android.R.color.white));
        dashboardView4.setStartAngle(150);
        dashboardView4.setPointerRadius(80);
        dashboardView4.setCircleRadius(8);
        dashboardView4.setSweepAngle(240);
        dashboardView4.setBigSliceCount(12);
        dashboardView4.setMaxValue(240);
        dashboardView4.setRealTimeValue(80);
        dashboardView4.setMeasureTextSize(14);
        dashboardView4.setHeaderRadius(50);
        dashboardView4.setHeaderTitle("km/h");
        dashboardView4.setHeaderTextSize(16);
        dashboardView4.setStripeWidth(20);
        dashboardView4.setStripeMode(DashboardView.StripeMode.OUTER);
        List<HighlightCR> highlight3 = new ArrayList<>();
        highlight3.add(new HighlightCR(150, 100, Color.parseColor("#4CAF50")));
        highlight3.add(new HighlightCR(250, 80, Color.parseColor("#FFEB3B")));
        highlight3.add(new HighlightCR(330, 60, Color.parseColor("#F44336")));
        dashboardView4.setStripeHighlightColorAndRange(highlight3);



        scoreTrend = (ScoreTrend) findViewById(R.id.scoreTrend);

        int max = 700;
        int min = 650;

        Random ramdom = new Random();
        for(int i = 0; i < 6; i++)
        {
            score[i] = ramdom.nextInt(max) % (max - min + 1) + min;
        }
        scoreTrend.setScore(score);


    }
}
